package homework;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class demo15 {
    public static void main(String[] args) {
        ThreadPoolExecutor threadPool = new ThreadPoolExecutor(5,//核心线程数
        10,//最大线程数
        3,//线程空闲时长
        TimeUnit.SECONDS,//时间单位
        new ArrayBlockingQueue<>(100),//阻塞队列
        new ThreadPoolExecutor.DiscardOldestPolicy()//拒绝策略
        );

        for (int i = 0; i < 2000; i++) {
            new Thread(() -> {
                System.out.println(Thread.currentThread().getName() + "执行任务");
            },"thread" + (i + 1)).start();
        }
    }
}
